//
//  ViewController.m
//  LPFWechatOfficeAccount
//
//  Created by 李鹏飞 on 2020/7/1.
//  Copyright © 2020 李鹏飞. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@property (weak, nonatomic) IBOutlet UIPageControl *pageControl;
@property (weak, nonatomic) IBOutlet UIButton *btn;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    NSInteger currentPage = 0;
    if (self.scrollView.contentOffset.x != 0) {
        currentPage = self.scrollView.contentSize.width/(self.scrollView.contentSize.width - self.scrollView.contentOffset.x);
    }
    self.pageControl.currentPage = currentPage;
    if (currentPage == 0) {
        [self.btn setTitle:@"0" forState:UIControlStateNormal];
    }else if (currentPage == 1){
        [self.btn setTitle:@"1" forState:UIControlStateNormal];
    }else if (currentPage == 2){
        [self.btn setTitle:@"2" forState:UIControlStateNormal];
    }else if (currentPage == 3){
        [self.btn setTitle:@"3" forState:UIControlStateNormal];
    }
    
    
}

@end
